extends ../layout

block css
    link(rel='stylesheet', href='/css/base/ck_base.css', media='screen')
    link(rel='stylesheet', href='/css/user/ck_set.css', media='screen')
block js
    script(src='/js/jquery-1.8.0.min.js')
    script(src='/js/html5.js')
    script(src='/js/jquery.common.js')
    script(src='/js/user/util.js')
block content

    .set_wrap.clearfix
      aside.set_sidebar
        .nav_hd 设置中心
        ul.sidetab
          li.curr
            a.icoR_11(href='/info') 个人资料
          li
            a.icoR_20(href='/info/address') 收货地址
          li
            a.icoR_12(href='/info/icon') 设置头像
          li
            a.icoR_15(href='/info/pwd') 帐号安全
          li
            a.icoR_21(href='/info/school') 所在学校            
      .set_content.personal_info.shipping_add.shipping_add_focus
        .pi_bd.clearfix
          .sa_title
            | 个人资料

          form.formH.grzlForm.clearfix
            input#uid(type='hidden', value='#{uid}')

            // =E formItem
            // =E formItem
            .formItem.mb20
              label.form_label(for='') 昵称：
              .form_field
                input#nickname.form_text(type='text', value='#{nickname}')
            // =E formItem
            .formItem.mb20
              label.form_label(for='') 个性签名：
              .form_field
                input#sign.form_text(type='text', value='#{sign}')
            // =E formItem
            .formItem.mb20
              label.form_label(for='') 真实姓名：
              .form_field
                input#realname.form_text(type='text', value='#{realname}')
            // =E formItem
            .formItem.mb20
              label.form_label(for='') 性别：
              .form_field
                span.mr20
                  input#na(type='radio', value='1', name='sex')
                  |  男
                span
                  input#nv(type='radio', value='2', name='sex')
                  |  女
            // =E formItem
            .formItem.mb20
              label.form_label(for='') 手机：
              .form_field
                input#mobile.form_text(type='text', maxlength='11', value='#{mobile}')
                span(style='margin-left:10px;') 
            // =E formItem
            .formItem.mb20
              label.form_label(for='') 备用邮箱：
              .form_field
                input#email.form_text(type='text', value='#{email}')
            // =E formItem
                .formItem.mb20
                  label.form_label(for='') 所在城市：
                  .form_field
                    #cascader_city
            // =E formItem
            .formItem.mb20
              label.form_label(for='') 个人说明：
              .form_field
                textarea#desc(rows='10', cols='30') #{desc}
            // =E formItem
            .formItem.mb20
              label.form_label(for='')  
              .form_field
                p.mb10
                  a#saveBtn.n_btn38g(href='javascript:;') 保存
            // =E formItem
        // =E grzl_bd

      script.
        //var data = !{JSON.stringify(city)};
        //var cascader_city = JSON.parse(data);
        var checkMobile = function(mobile) {
        var regular = /^[(86)|0]?(13\d{9})|(15\d{9})|(17\d{9})|(18\d{9})$/g;
        if (!regular.test(mobile)) {
        return false;
        }
        return true;
        };        
        $(function(){
        var gender = #{sex};
        if(gender == 1){
        $('#na').attr("checked",'checked');
        }else{
        $('#nv').attr("checked",'checked');
        }
        $("#saveBtn").click(function(){
        var mobile = $("#mobile").val();
        var email = $("#email").val();
        var desc = $("#desc").val();
        var nickname = $("#nickname").val();
        var sign = $("#sign").val();
        var realname = $("#realname").val();
        var sex = $(":radio[name='sex'][checked=true]").val();
        var uid = $("#uid").val();
        if (!checkMobile(mobile)){
        $.alertBoxy({message : '请填写正确的手机号码！'});
        return false;
        }
        var params = "nickname="+encodeURIComponent(nickname)+"&sign="+encodeURIComponent(sign)+"&realname="+encodeURIComponent(realname)+"&sex="+sex+"&uid="+uid;
        params += "&mobile="+mobile+"&email="+encodeURIComponent(email)+"&desc="+encodeURIComponent(desc);
        var tipboxy = false;
        $.ajax({
        url:"/info/saveBasic",
        type:"post",
        data:params,
        dataType:"json",
        async : false,
        beforeSend:function(){
        tipboxy = $.tipsBoxy({type:"loading", message : "数据提交中...", mask : true});
        },
        success:function(ret) {
        tipboxy.cancel();
        if (ret.code == 0) {
        $.tipsBoxy({message : "资料修改成功", mask : true});
        } else {
        $.alertBoxy({message : ret.result});
        }
        }
        });
        });
        });
      //script(src='/js/user/city.js')
